package com.softer.wxzj.controller;

import com.github.pagehelper.PageInfo;
import com.softer.wxzj.common.aop.annotation.LogRecord;
import com.softer.wxzj.common.aop.enums.LogOperationType;
import com.softer.wxzj.common.aop.enums.LogOperationUnit;
import com.softer.wxzj.common.entity.CommonResult;
import com.softer.wxzj.common.entity.Page;
import com.softer.wxzj.entity.BaseSubRegionInfo;
import com.softer.wxzj.service.BaseSubRegionInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @program: wxzj
 * @author: wxr
 * @create: 2019-05-20 16:15
 **/
@RestController
@RequestMapping("/baseSubRegionInfo")
@Slf4j
public class BaseSubRegionInfoController {
    @Autowired
    private BaseSubRegionInfoService baseSubRegionInfoService;
    /**
     * 分区添加
     * @param baseSubRegionInfo
     * @return
     */
    @RequestMapping("/add")
    @LogRecord(description = "分区添加",operationUnit = LogOperationUnit.BASE_SUB_REGION_INFO,operationType = LogOperationType.INSERT)
    public CommonResult insert(BaseSubRegionInfo baseSubRegionInfo) {
        return baseSubRegionInfoService.insert(baseSubRegionInfo);
    }

    /**
     * 分区修改
     * @param baseSubRegionInfo
     * @return
     */
    @RequestMapping("/update")
    @LogRecord(description = "分区修改",operationUnit = LogOperationUnit.BASE_SUB_REGION_INFO,operationType = LogOperationType.UPDATE)
    public CommonResult update(BaseSubRegionInfo baseSubRegionInfo) {
        return baseSubRegionInfoService.update(baseSubRegionInfo);
    }

    /**
     * 分区删除
     * @param id
     * @return
     */
    @RequestMapping("/delete")
    @LogRecord(description = "加密狗删除",operationUnit = LogOperationUnit.BASE_SUB_REGION_INFO,operationType = LogOperationType.DELETE)
    public CommonResult delete(String id) {
        return baseSubRegionInfoService.delete(id);
    }

    /**
     * 分区查看
     * @param page
     * @param baseSubRegionInfo
     * @return
     */
    @RequestMapping("/getList")
    @LogRecord(description = "分区查看",operationUnit = LogOperationUnit.BASE_SUB_REGION_INFO,operationType = LogOperationType.SELECT)
    public PageInfo<BaseSubRegionInfo> getList(Page page, BaseSubRegionInfo baseSubRegionInfo) {
        return baseSubRegionInfoService.getList(page,baseSubRegionInfo);
    }
    /**
     * 分区查看单个信息
     * @param id
     * @return
     */
    @RequestMapping("/getInfo")
    @LogRecord(description = "分区查看单个信息",operationUnit = LogOperationUnit.BASE_SUB_REGION_INFO,operationType = LogOperationType.SELECT)
    public BaseSubRegionInfo getInfo( String id) {
        return baseSubRegionInfoService.getInfo(id);
    }

    /**
     * 分区列表，不分页
     * @param baseSubRegionInfo
     * @return
     */
    @RequestMapping("/getAllList")
    @LogRecord(description = "查询分区列表，不分页",operationUnit = LogOperationUnit.BASE_SUB_REGION_INFO,operationType = LogOperationType.SELECT)
    public List<BaseSubRegionInfo> getAllList(BaseSubRegionInfo baseSubRegionInfo) {
        return baseSubRegionInfoService.getAllList(baseSubRegionInfo);
    }
    /**
     * 分区下拉列表
     * @param id
     * @return
     */
    @RequestMapping("/selectDown")
    @LogRecord(description = "查询分区列表，不分页",operationUnit = LogOperationUnit.BASE_SUB_REGION_INFO,operationType = LogOperationType.SELECT)
    public List<BaseSubRegionInfo> selectDown(String id){
        return  baseSubRegionInfoService.selectDown(id);
    }
}
